1
|
|
|
/*! Bulk Delete - v5.6.1 %> |
2
|
|
|
* https://bulkwp.com |
3
|
|
|
* Copyright (c) 2018; * Licensed GPLv2+ */ |
4
|
|
|
/*global BulkWP, postboxes, pagenow */ |
5
|
|
|
jQuery(document).ready(function () { |
6
|
|
|
// Start Jetpack. |
7
|
|
|
BulkWP.jetpack(); |
8
|
|
|
|
9
|
|
|
BulkWP.enableHelpTooltips( jQuery( '.bd-help' ) ); |
10
|
|
|
|
11
|
|
|
jQuery( '.user_restrict_to_no_posts_filter' ).change( function() { |
12
|
|
|
var $this = jQuery(this), |
13
|
|
|
filterEnabled = $this.is( ':checked' ), |
14
|
|
|
$filterItems = $this.parents( 'table' ).children().find( '.user_restrict_to_no_posts_filter_items' ); |
15
|
|
|
|
16
|
|
|
if ( filterEnabled ) { |
17
|
|
|
$filterItems.removeClass( 'visually-hidden' ); |
18
|
|
|
} else { |
19
|
|
|
$filterItems.addClass( 'visually-hidden' ); |
20
|
|
|
} |
21
|
|
|
} ); |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Enable Postbox handling |
25
|
|
|
*/ |
26
|
|
|
postboxes.add_postbox_toggles(pagenow); |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Toggle the date restrict fields |
30
|
|
|
*/ |
31
|
|
|
function toggle_date_restrict(el) { |
32
|
|
|
if (jQuery("#smbd" + el + "_restrict").is(":checked")) { |
33
|
|
|
jQuery("#smbd" + el + "_op").removeAttr('disabled'); |
34
|
|
|
jQuery("#smbd" + el + "_days").removeAttr('disabled'); |
35
|
|
|
} else { |
36
|
|
|
jQuery("#smbd" + el + "_op").attr('disabled', 'true'); |
37
|
|
|
jQuery("#smbd" + el + "_days").attr('disabled', 'true'); |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Toggle limit restrict fields |
43
|
|
|
*/ |
44
|
|
|
function toggle_limit_restrict(el) { |
45
|
|
|
if (jQuery("#smbd" + el + "_limit").is(":checked")) { |
46
|
|
|
jQuery("#smbd" + el + "_limit_to").removeAttr('disabled'); |
47
|
|
|
} else { |
48
|
|
|
jQuery("#smbd" + el + "_limit_to").attr('disabled', 'true'); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Toggle user login restrict fields |
54
|
|
|
*/ |
55
|
|
|
function toggle_login_restrict(el) { |
56
|
|
|
if (jQuery("#smbd" + el + "_login_restrict").is(":checked")) { |
57
|
|
|
jQuery("#smbd" + el + "_login_days").removeAttr('disabled'); |
58
|
|
|
} else { |
59
|
|
|
jQuery("#smbd" + el + "_login_days").attr('disabled', 'true'); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Toggle user registered restrict fields |
65
|
|
|
*/ |
66
|
|
|
function toggle_registered_restrict(el) { |
67
|
|
|
if (jQuery("#smbd" + el + "_registered_restrict").is(":checked")) { |
68
|
|
|
jQuery("#smbd" + el + "_registered_days").removeAttr('disabled'); |
69
|
|
|
} else { |
70
|
|
|
jQuery("#smbd" + el + "_registered_days").attr('disabled', 'true'); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Toggle Post type dropdown. |
76
|
|
|
*/ |
77
|
|
|
function toggle_post_type_dropdown( el ) { |
78
|
|
|
// TODO: Check why the element is not toggling even when display:none is added by JS. |
79
|
|
|
if ( jQuery( "#smbd" + el + "_no_posts" ).is( ":checked" ) ) { |
80
|
|
|
jQuery( "tr#smbd" + el + "-post-type-dropdown" ).show(); |
81
|
|
|
} else { |
82
|
|
|
jQuery( "tr#smbd" + el + "-post-type-dropdown" ).hide(); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
// hide all terms |
87
|
|
|
function hideAllTerms() { |
88
|
|
|
jQuery('table.terms').hide(); |
89
|
|
|
jQuery('input.terms').attr('checked', false); |
90
|
|
|
} |
91
|
|
|
// call it for the first time |
92
|
|
|
hideAllTerms(); |
93
|
|
|
|
94
|
|
|
// taxonomy click handling |
95
|
|
|
jQuery('.custom-tax').change(function () { |
96
|
|
|
var $this = jQuery(this), |
97
|
|
|
$tax = $this.val(), |
98
|
|
|
$terms = jQuery('table.terms_' + $tax); |
99
|
|
|
|
100
|
|
|
if ($this.is(':checked')) { |
101
|
|
|
hideAllTerms(); |
102
|
|
|
$terms.show('slow'); |
103
|
|
|
} |
104
|
|
|
}); |
105
|
|
|
|
106
|
|
|
// date time picker |
107
|
|
|
jQuery.each(BulkWP.dt_iterators, function (index, value) { |
108
|
|
|
// invoke the date time picker |
109
|
|
|
jQuery('#smbd' + value + '_cron_start').datetimepicker({ |
110
|
|
|
dateFormat: 'yy-mm-dd', |
111
|
|
|
timeFormat: 'HH:mm:ss' |
112
|
|
|
}); |
113
|
|
|
|
114
|
|
|
jQuery('#smbd' + value + '_restrict').change(function () { |
115
|
|
|
toggle_date_restrict(value); |
116
|
|
|
}); |
117
|
|
|
|
118
|
|
|
jQuery('#smbd' + value + '_limit').change(function () { |
119
|
|
|
toggle_limit_restrict(value); |
120
|
|
|
}); |
121
|
|
|
|
122
|
|
|
jQuery('#smbd' + value + '_login_restrict').change(function () { |
123
|
|
|
toggle_login_restrict(value); |
124
|
|
|
}); |
125
|
|
|
|
126
|
|
|
jQuery('#smbd' + value + '_registered_restrict').change(function () { |
127
|
|
|
toggle_registered_restrict(value); |
128
|
|
|
}); |
129
|
|
|
|
130
|
|
|
jQuery( '#smbd' + value + '_no_posts' ).change( function () { |
131
|
|
|
toggle_post_type_dropdown( value ); |
132
|
|
|
}); |
133
|
|
|
}); |
134
|
|
|
|
135
|
|
|
jQuery.each( BulkWP.pro_iterators, function ( index, value) { |
136
|
|
|
jQuery('.bd-' + value.replace( '_', '-' ) + '-pro').hide(); |
137
|
|
|
jQuery('#smbd_' + value + '_cron_freq, #smbd_' + value + '_cron_start, #smbd_' + value + '_cron').removeAttr('disabled'); |
138
|
|
|
} ); |
139
|
|
|
|
140
|
|
|
// Validate user action |
141
|
|
|
jQuery('button[name="bd_action"]').click(function () { |
142
|
|
|
var currentButton = jQuery(this).val(), |
143
|
|
|
valid = false, |
144
|
|
|
msg_key = "deletePostsWarning", |
145
|
|
|
error_key = "selectPostOption"; |
146
|
|
|
|
147
|
|
|
if (currentButton in BulkWP.validators) { |
148
|
|
|
valid = BulkWP[BulkWP.validators[currentButton]](this); |
149
|
|
|
} else { |
150
|
|
|
if (jQuery(this).parent().prev().children('table').find(":checkbox:checked[value!='true']").size() > 0) { // monstrous selector |
151
|
|
|
valid = true; |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
if (valid) { |
156
|
|
|
if (currentButton in BulkWP.pre_action_msg) { |
157
|
|
|
msg_key = BulkWP.pre_action_msg[currentButton]; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
return confirm(BulkWP.msg[msg_key]); |
161
|
|
|
} else { |
162
|
|
|
if (currentButton in BulkWP.error_msg) { |
163
|
|
|
error_key = BulkWP.error_msg[currentButton]; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
alert(BulkWP.msg[error_key]); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
return false; |
170
|
|
|
}); |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Validation functions |
174
|
|
|
*/ |
175
|
|
|
BulkWP.noValidation = function() { |
176
|
|
|
return true; |
177
|
|
|
}; |
178
|
|
|
|
179
|
|
|
BulkWP.validateSelect2 = function(that) { |
180
|
|
|
if (null !== jQuery(that).parent().prev().children().find(".select2[multiple]").val()) { |
181
|
|
|
return true; |
182
|
|
|
} else { |
183
|
|
|
return false; |
184
|
|
|
} |
185
|
|
|
}; |
186
|
|
|
|
187
|
|
|
BulkWP.validateUrl = function(that) { |
188
|
|
|
if (jQuery(that).parent().prev().children('table').find("textarea").val() !== '') { |
189
|
|
|
return true; |
190
|
|
|
} else { |
191
|
|
|
return false; |
192
|
|
|
} |
193
|
|
|
}; |
194
|
|
|
|
195
|
|
|
BulkWP.validateUserMeta = function() { |
196
|
|
|
if (jQuery('#smbd_u_meta_value').val() !== '') { |
197
|
|
|
return true; |
198
|
|
|
} else { |
199
|
|
|
return false; |
200
|
|
|
} |
201
|
|
|
}; |
202
|
|
|
}); |
203
|
|
|
|
204
|
|
|
BulkWP.jetpack = function() { |
205
|
|
|
jQuery('.bd-feedback-pro').hide(); |
206
|
|
|
|
207
|
|
|
jQuery('#smbd_feedback_cron_freq, #smbd_feedback_cron_start, #smbd_feedback_cron').removeAttr('disabled'); |
208
|
|
|
jQuery('#smbd_feedback_use_filter').removeAttr('disabled'); |
209
|
|
|
|
210
|
|
|
// enable filters |
211
|
|
|
jQuery('input[name="smbd_feedback_use_filter"]').change(function() { |
212
|
|
|
if('true' === jQuery(this).val()) { |
213
|
|
|
// using filters |
214
|
|
|
jQuery('#jetpack-filters').show(); |
215
|
|
|
} else { |
216
|
|
|
jQuery('#jetpack-filters').hide(); |
217
|
|
|
} |
218
|
|
|
}); |
219
|
|
|
|
220
|
|
|
// enable individual filters |
221
|
|
|
jQuery.each(['name', 'email', 'ip'], function (index, value) { |
222
|
|
|
jQuery('#smbd_feedback_author_' + value + '_filter').change(function() { |
223
|
|
|
if(jQuery(this).is(':checked')) { |
224
|
|
|
jQuery('#smbd_feedback_author_' + value + '_op').removeAttr('disabled'); |
225
|
|
|
jQuery('#smbd_feedback_author_' + value + '_value').removeAttr('disabled'); |
226
|
|
|
} else { |
227
|
|
|
jQuery('#smbd_feedback_author_' + value + '_op').attr('disabled', 'true'); |
228
|
|
|
jQuery('#smbd_feedback_author_' + value + '_value').attr('disabled', 'true'); |
229
|
|
|
} |
230
|
|
|
}); |
231
|
|
|
}); |
232
|
|
|
}; |
233
|
|
|
|
234
|
|
|
BulkWP.enableHelpTooltips = function ( $selector ) { |
235
|
|
|
$selector.tooltip({ |
236
|
|
|
content: function() { |
237
|
|
|
return jQuery(this).prop('title'); |
238
|
|
|
}, |
239
|
|
|
position: { |
240
|
|
|
my: 'center top', |
241
|
|
|
at: 'center bottom+10', |
242
|
|
|
collision: 'flipfit' |
243
|
|
|
}, |
244
|
|
|
hide: { |
245
|
|
|
duration: 200 |
246
|
|
|
}, |
247
|
|
|
show: { |
248
|
|
|
duration: 200 |
249
|
|
|
} |
250
|
|
|
}); |
251
|
|
|
}; |
252
|
|
|
|
253
|
|
|
/*global ajaxurl*/ |
254
|
|
|
jQuery( document ).ready( function () { |
255
|
|
|
/** |
256
|
|
|
* Normal select2. |
257
|
|
|
*/ |
258
|
|
|
jQuery( '.select2-taxonomy' ).select2( { |
259
|
|
|
width: '300px' |
260
|
|
|
} ); |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* Enable AJAX for Taxonomy Select2. |
264
|
|
|
*/ |
265
|
|
|
jQuery( '.select2-taxonomy-ajax' ).select2( { |
266
|
|
|
ajax: { |
267
|
|
|
url: ajaxurl, |
268
|
|
|
dataType: 'json', |
269
|
|
|
delay: 250, |
270
|
|
|
data: function ( params ) { |
271
|
|
|
return { |
272
|
|
|
q: params.term, |
273
|
|
|
taxonomy: jQuery( this ).attr( 'data-taxonomy' ), |
274
|
|
|
action: 'bd_load_taxonomy_term' |
275
|
|
|
}; |
276
|
|
|
}, |
277
|
|
|
processResults: function ( data ) { |
278
|
|
|
var options = []; |
279
|
|
|
|
280
|
|
|
if ( data ) { |
281
|
|
|
jQuery.each( data, function ( index, dataPair ) { |
282
|
|
|
options.push( { id: dataPair[ 0 ], text: dataPair[ 1 ] } ); |
283
|
|
|
} ); |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
return { |
287
|
|
|
results: options |
288
|
|
|
}; |
289
|
|
|
}, |
290
|
|
|
cache: true |
291
|
|
|
}, |
292
|
|
|
minimumInputLength: 2, // the minimum of symbols to input before perform a search |
293
|
|
|
width: '300px' |
294
|
|
|
} ); |
295
|
|
|
|
296
|
|
|
jQuery( '.select2-post' ).select2( { |
297
|
|
|
width: '300px', |
298
|
|
|
templateSelection: formatLabel |
299
|
|
|
} ); |
300
|
|
|
} ); |
301
|
|
|
|
302
|
|
|
function formatLabel (state) { |
303
|
|
|
if (!state.id) { |
304
|
|
|
return state.text; |
305
|
|
|
} |
306
|
|
|
var parentLabel = state.element.parentElement.label; |
307
|
|
|
var $state = jQuery( |
308
|
|
|
'<span>' + parentLabel + '-' + state.text + '</span>' |
309
|
|
|
); |
310
|
|
|
return $state; |
311
|
|
|
}; |
312
|
|
|
//# sourceMappingURL=bulk-delete.js.map |